<%include file="header.html"%> <%include file="top.html"%> <%include
file="left.html"%>
<div class="main-content">
<div class="breadcrumbs" id="breadcrumbs"><script
	type="text/javascript">
	try {
		ace.settings.check('breadcrumbs', 'fixed')
	} catch (e) {
	}
</script>

<ul class="breadcrumb">
	<li><i class="icon-home home-icon"></i> <a
		href="index.php">首页</a></li>
</ul>
<!-- .breadcrumb --></div>

<div class="page-content">




<div id="moveDevice" style="display:none" class="col-xs-12">
<div class="alert alert-info">
<form class="form-horizontal" role="form">
<div class="row">

<div class="col-sm-12">
<div class="row">
<label class="col-sm-5 control-label no-padding-right" for="form-field-5">游戏</label>
<div class="col-sm-3"><select id="selectGame2">
	<option value="" >游戏</option>
	<%if $selectGames%> <%foreach from = $selectGames key = key item = value%>
	<%if $nowGame == $value %>
	<option value="<%$value%>" selected><%$value%></option>
	<%else%>
	<option value="<%$value%>"><%$value%></option>
	<%/if%> <%/foreach%> <%/if%>
</select>
</div>
</div>
</div>

<div class="col-sm-12">
<div  class="row">
<label class="col-sm-5 control-label no-padding-right" for="form-field-5"></label>
</div>
</div>

<div class="col-sm-12">
<div class="row"><label
	class="col-sm-5 control-label no-padding-right" for="form-field-5">日期</label>
<div class="col-sm-3">
<div class="input-group">

<span  class="input-group-addon"> 
<i onclick="before2();" class="icon-arrow-left bigger-110"></i> </span> <input
	class="date-picker col-xs-12 col-sm-12" id="startTime2"
	value="<%$startDate%>" type="text" data-date-format="yyyy-mm-dd" />
<span class="input-group-addon"> 
<i onclick="after2();" class="icon-arrow-right bigger-110"></i> 
</span>	
	
</div>

</div>
</div>
</div>




<div class="col-sm-12">
<div  class="row">
<label class="col-sm-5 control-label no-padding-right" for="form-field-5"></label>
</div>
</div>

<div class="col-sm-12">
<div class="row"><label
	class="col-sm-5 control-label no-padding-right" for="form-field-5">&nbsp;&nbsp;&nbsp;&nbsp;</label>
<div class="col-sm-3">
<center>
<button type="button" onClick="formSubmit('select', 'move');"
	class="width-50 btn btn-sm btn-primary">渠道查询</button>
</center>
</div>

</div>
</div>

<div class="col-sm-12">
<div  class="row">
<label class="col-sm-5 control-label no-padding-right" for="form-field-5"></label>
</div>
</div>

<div class="col-sm-12">
<div class="row"><label
	class="col-sm-5 control-label no-padding-right" for="form-field-5">&nbsp;&nbsp;&nbsp;&nbsp;</label>

<div class="col-sm-3">
<center>
<button type="button" onClick="formSubmit2('select', 'pc');"
	class="width-50 btn btn-sm btn-primary">平台查询</button>
</center>
</div>

</div>
</div>

</div>
</form>
</div>
</div>

<div id="pcDevice" style="display:block" class="col-xs-12">
<div class="alert alert-info">
<form class="form-horizontal" role="form">
<div class="row">

<div class="col-sm-4">
<div class="row">
<label class="col-sm-2 control-label no-padding-right" for="form-field-5">游戏</label>
<div class="col-sm-3"><select id="selectGame">
	<option value="" >游戏</option>
	<%if $selectGames%> <%foreach from = $selectGames key = key item = value%>
	<%if $nowGame == $value %>
	<option value="<%$value%>" selected><%$value%></option>
	<%else%>
	<option value="<%$value%>"><%$value%></option>
	<%/if%> <%/foreach%> <%/if%>
</select>
</div>
</div>
</div>


<div class="col-sm-4">
<label class="col-sm-2 control-label no-padding-right" for="form-field-5">日期</label>
<div class="col-sm-6">
<div class="input-group">
<span  class="input-group-addon"> 
<i onclick="before();" class="icon-arrow-left bigger-110"></i> 
</span> 
<input class="date-picker col-xs-12 col-sm-12" id="startTime" value="<%$startDate%>" type="text" data-date-format="yyyy-mm-dd" />
<span class="input-group-addon"> 
<i onclick="after();" class="icon-arrow-right bigger-110"></i> 
</span> 
</div>
</div>
</div>


<div class="col-sm-4">
<div class="row"><label
	class="col-sm-2 control-label no-padding-right" for="form-field-5">&nbsp;&nbsp;&nbsp;&nbsp;</label>
<div class="col-sm-4">
<center>
<button type="button" onClick="formSubmit('select', 'pc');"
	class="width-50 btn btn-sm btn-primary">渠道查询</button>
</center>
</div>


<div class="col-sm-4">
<center>
<button type="button" onClick="formSubmit2('select', 'pc');"
	class="width-50 btn btn-sm btn-primary">平台查询</button>
</center>
</div>

</div>
</div>

</div>

</div>
</form>
</div>
</div>



<div class="col-xs-12">
<div class="table-header">
分类信息
<!-- 
<button type="button" 
	class="width-10 btn btn-sm btn-primary">
</button>


<button type="button"  onClick="formSubmit('daochu', 'pc');"
	class="width-10 btn btn-sm btn-primary">导出结果
</button>
 -->

</div>



<div id="view"  class="table-responsive">
<table id="sample-table-4"
	class="table table-striped table-bordered table-hover">
	<thead>
		<tr>
			<th>平台</th>
			<th>DAU</th>
			<th>设备新增</th>
			<th>用户次留</th>
			<th>设备次留</th>
			<th>付费额</th>
			<th>付费率</th>
			<th>付费UP</th>
			<th>人均UP</th>
		</tr>
	<thead/>
	<tbody>
		<%foreach from=$platformDataArr item=data%>
		<tr>
			<td><%$data.platform%> <%$data.channel%> </td>
			<td><%$data.deviceLogin%></td>
			<td><%$data.newDevice%></td>
			<td><%$data.userRetention2%></td>
			<td><%$data.deviceRetention2%></td>	
			<td><%$data.payMoney%></td>
			<td><%$data.PayRate%></td>
			<td><%$data.ARPU%></td>
			<td><%$data.ARPPU%></td>
		</tr>
		<%/foreach%>

	</tbody>
</table>
</div>


<!-- /.table-responsive --></div>
</div>
<!-- /.page-content --></div>
<!-- /.main-content -->
<script type="text/javascript">
	 function before() {
		var startTime = $('#startTime').val();
	    var   today =new   Date(startTime); 
	    var yesterday_milliseconds=today.getTime()-1000*60*60*24;        
	    var yesterday = new Date();        
	        yesterday.setTime(yesterday_milliseconds);        
	    var strYear = yesterday.getFullYear();     
	    var strDay = yesterday.getDate();     
	    var strMonth = yesterday.getMonth()+1;   
	    if(strMonth<10)     
	    {     
	        strMonth="0"+strMonth;     
	    }     
	    datastr = strYear+"-"+strMonth+"-"+strDay;  
		document.getElementById("startTime").value= datastr;
	 }
	 
	 function after() {
		 var startTime = $('#startTime').val();
		    var   today =new   Date(startTime); 
		    var yesterday_milliseconds=today.getTime()+1000*60*60*24;        
		    var yesterday = new Date();        
		        yesterday.setTime(yesterday_milliseconds);        
		    var strYear = yesterday.getFullYear();     
		    var strDay = yesterday.getDate();     
		    var strMonth = yesterday.getMonth()+1;   
		    if(strMonth<10)     
		    {     
		        strMonth="0"+strMonth;     
		    }     
		    datastr = strYear+"-"+strMonth+"-"+strDay;  
			document.getElementById("startTime").value= datastr;
	 }

	 function before2() {
			var startTime = $('#startTime2').val();
		    var   today =new   Date(startTime); 
		    var yesterday_milliseconds=today.getTime()-1000*60*60*24;        
		    var yesterday = new Date();        
		        yesterday.setTime(yesterday_milliseconds);        
		    var strYear = yesterday.getFullYear();     
		    var strDay = yesterday.getDate();     
		    var strMonth = yesterday.getMonth()+1;   
		    if(strMonth<10)     
		    {     
		        strMonth="0"+strMonth;     
		    }     
		    datastr = strYear+"-"+strMonth+"-"+strDay;  
			document.getElementById("startTime2").value= datastr;
		 }
		 
	 function after2() {
		 var startTime = $('#startTime2').val();
		    var   today =new   Date(startTime); 
		    var yesterday_milliseconds=today.getTime()+1000*60*60*24;        
		    var yesterday = new Date();        
		        yesterday.setTime(yesterday_milliseconds);        
		    var strYear = yesterday.getFullYear();     
		    var strDay = yesterday.getDate();     
		    var strMonth = yesterday.getMonth()+1;   
		    if(strMonth<10)     
		    {     
		        strMonth="0"+strMonth;     
		    }     
		    datastr = strYear+"-"+strMonth+"-"+strDay;  
			document.getElementById("startTime2").value= datastr;
	 }
	 
	jQuery(function($) {
		$('.date-picker').datepicker({
			autoclose : true
		}).next().on(ace.click_event, function() {
			$(this).prev().focus();
		});

		var oTable1 = $('#sample-table-2').dataTable({
			"aoColumns" : [ {
				"bSortable" : false
			}, {
				"bSortable" : false
			}, {
				"bSortable" : false
			}, {
				"bSortable" : false
			}, {
				"bSortable" : false
			}, {
				"bSortable" : false
			}, {
				"bSortable" : false
			}
			]
		});
/*
		$('[data-rel="tooltip"]').tooltip({
			placement : tooltip_placement
		});
		function tooltip_placement(context, source) {
			var $source = $(source);
			var $parent = $source.closest('table')
			var off1 = $parent.offset();
			var w1 = $parent.width();
			var off2 = $source.offset();
			var w2 = $source.width();
			if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2))
				return 'right';
			return 'left';
		}
*/	
	});

	// 渠道
	function formSubmit(type, device) {
		if(device == "pc") {
			var game = $('#selectGame').val();
			var startTime = $('#startTime').val();
		} else if(device == "move") {
			var game = $('#selectGame2').val();
			var startTime = $('#startTime2').val();
		}
		
		if (!game || !startTime) {
			alert('请将信息填写完整！');
		} else {
				url = "index.php?mod=Data&do=getPlatformData&game="
					+ game
					+ "&date="
					+ startTime
			window.location.href = url;
		}
	}
	
	// 平台
	function formSubmit2(type, device) {
		if(device == "pc") {
			var game = $('#selectGame').val();
			var startTime = $('#startTime').val();
			
		} else if(device == "move") {
			var game = $('#selectGame2').val();
			var startTime = $('#startTime2').val();
		}
		
		if (!game || !startTime) {
			alert('请将信息填写完整！');
		} else {
				url = "index.php?mod=Data&do=getChannelData&game="
					+ game
					+ "&date="
					+ startTime
			window.location.href = url;
		}
	}
	
	
	window.onload = function(){
		
		var width = document.documentElement.clientWidth;
		if(width < 1425) {
			$('#pcDevice').css("display", "none");
			$('#moveDevice').css("display", "block");
		} else if(width > 1425) {
			$('#pcDevice').css("display", "block");
			$('#moveDevice').css("display", "none");
		}
		
		// pc设备
	    var select = document.getElementById('selectGame');
	    select.onchange = function(){
	    	
	        // 更改值后执行的代码
	       var gameName = jQuery("#selectGame  option:selected").text();
	       var _tagNum = 1;
	       $.ajax({
	    	    type: "POST",
				url: "index.php?mod=Game&do=getPlatformByGame&game=" + gameName,
				data: "",
				dataType: 'html',
				success: function(data) {					
					var dataObj = eval("(" + data + ")");//转换为json对象
					
					if(dataObj == null) {
						$("#platform").empty();
						$("#platform").append('<option value="" id="selectPlatform">平台</option>');
						$("#channel").empty();
						$("#channel").append('<option value="" id="selectChannel">渠道</option>');
					}
					
					var platform = dataObj.platform;
					$("#platform").empty();
					$("#platform").append('<option value="" id="selectPlatform">平台</option>');
					for(var i=0;i<platform.length;i++){
						$("#platform").append("<option value='"+platform[i]+"' >"+platform[i]+"</option>"+"<br/>");
					}
					
					var channel = dataObj.channel;
					$("#channel").empty();
					$("#channel").append('<option value="" id="selectChannel">渠道</option>');
					for(var i=0;i<channel.length;i++){
						$("#channel").append("<option value='"+channel[i]+"' >"+channel[i]+"</option>"+"<br/>");
					}
				}
	       });
	    }
	    
	    
	    // 移动设备
	    var select2 = document.getElementById('selectGame2');
	    select2.onchange = function(){
	        // 更改值后执行的代码
	       var gameName = jQuery("#selectGame2  option:selected").text();
	       $.ajax({
	    	    type: "POST",
				url: "index.php?mod=Game&do=getPlatformByGame&game=" + gameName,
				data: "",
				dataType: 'html',
				success: function(data) {					
					var dataObj = eval("(" + data + ")");//转换为json对象
					if(dataObj == null) {
						$("#platform2").empty();
						$("#platform2").append('<option value="" id="selectPlatform2">平台</option>');
						$("#channel2").empty();
						$("#channel2").append('<option value="" id="selectChannel2">渠道</option>');
					}
					
					var platform = dataObj.platform;
					$("#platform2").empty();
					$("#platform2").append('<option value="" id="selectPlatform2">平台</option>');
					for(var i=0;i<platform.length;i++){
						$("#platform2").append("<option value='"+platform[i]+"' >"+platform[i]+"</option>"+"<br/>");
					}
					
					var channel = dataObj.channel;
					$("#channel2").empty();
					$("#channel2").append('<option value="" id="selectChannel2">渠道</option>');
					for(var i=0;i<channel.length;i++){
						$("#channel2").append("<option value='"+channel[i]+"' >"+channel[i]+"</option>"+"<br/>");
					}
				}
	       });
	    }
	} 
	
</script>
<%include file="footer.html"%>

